package com.project.config;

import com.project.interceptor.CustomInterceptor;
import com.project.interceptor.ManagerInterceptor;
import com.project.interceptor.SendInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MVCConfig implements WebMvcConfigurer {
    @Autowired
    private CustomInterceptor customInterceptor;
    @Autowired
    private ManagerInterceptor managerInterceptor;
    @Autowired
    private SendInterceptor sendInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {//拦截器
        InterceptorRegistration customReg  =   registry.addInterceptor(customInterceptor);
        customReg.addPathPatterns("/custom/**");

        InterceptorRegistration managerReg  =   registry.addInterceptor(managerInterceptor);
        managerReg.addPathPatterns("/manager/**");

        InterceptorRegistration sendReg  =   registry.addInterceptor(sendInterceptor);
        sendReg.addPathPatterns("/send/**");




    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/productImg/**")

                .addResourceLocations("file:D:/boot/buybatisplus/productImg/");


    }
}
